<extend name="Public/base"/>
<block name="content">
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商品列表</strong>  <small></small></div>
      </div>

      <hr>

      <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
          <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs">
              <a href="{:U('goods/add_goods')}" type="button" class="am-btn am-btn-primary"><span class="am-icon-plus"></span> 新增</a>
            </div>
          </div>
        </div>
      </div>

      <div class="am-g">
        <div class="am-u-sm-12">
          <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
              <thead>
              <tr>
                <th class="table-id">货号</th>
                <th class="table-title">名称</th>
                <th class="table-title">总库存</th>
                <th class="table-title">已售</th>
                <th class="table-title">logo</th>
                <th class="table-type">商品售价</th>
                <!--<th class="table-type">类型</th>-->
                <!--<th class="table-type">可见性</th>-->
                <th class="table-set">是否上架</th>
                <th class="table-set">创建时间</th>
                <th class="table-set">操作</th>
              </tr>
              </thead>
              <php>
                $goods_type = C('goods_type');
              </php>
              <tbody>
              <volist name="data" id="vo">
                <tr>
                  <td>{$vo['id']}</td>
                  <td>{$vo['name']}</td>
                  <th>{$vo.repertory}</th>
                  <th>{$vo.sell}</th>
                  <td><img src="__ROOT__{$vo.logopath}" style="width: 40px;height: 40px"></td>
                  <td>{$vo['price']}</td>
                  <!--<td>{$goods_type[$vo['pro_type']]}</td>-->


                  <td><php>
                    echo $vo['status'] == 1?'已上架':'已下架';
                  </php></td>
                  <td>{$vo['create_time']|date="Y-m-d H:i:s",###}</td>
                  <php>
                    $text = $vo['status'] == 1?'下架此商品':'上架此商品';
                  </php>
                  <td>
                    <div class="am-btn-toolbar">
                      <div class="am-btn-group am-btn-group-xs">
                        <a href="{:U('edit_goods',array('id'=>$vo['id']))}" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>
                        <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only xiajia"  g="{$vo['id']}"><span class="am-icon-trash-o"></span>删除</button>
                        <button class="am-btn am-btn-default am-btn-xs  am-hide-sm-only xx"  g="{$vo['id']}" s="{$vo['status']}"><span class="am-icon-trash-o"></span>{$text}</button>
                      </div>
                    </div>
                  </td>
                </tr>
              </volist>
              </tbody>
            </table>
            <div class="am-cf">
              共 {$count} 条记录
              <div class="am-fr">
                <ul class="am-pagination">
                  {$page}
                  <!--<li class="am-disabled"><a href="#">«</a></li>-->
                  <!--<li class="am-active"><a href="#">1</a></li>-->
                  <!--<li><a href="#">2</a></li>-->
                  <!--<li><a href="#">3</a></li>-->
                  <!--<li><a href="#">4</a></li>-->
                  <!--<li><a href="#">5</a></li>-->
                  <!--<li><a href="#">»</a></li>-->

                </ul>
              </div>
            </div>
            <hr />
            <p>注：.....</p>
          </form>
        </div>

      </div>
    </div>

    <footer class="admin-content-footer">
      <hr>
    </footer>

  </div>

</block>

<block name="js">
  <script>
    $(function () {
        $('.xiajia').click(function () {

            var url = "{:U('del_goods')}";
            var g_id = $(this).attr('g');
            $.post(url,{id:g_id},function (data) {
                alert(data.msg);
                if(data.code){
                    return;
                }else{
                    window.location.href=data.data;
                }
            },'json')
        });

        $('.xx').click(function () {

            var url = "{:U('xiajia_goods')}";
            var g_id = $(this).attr('g');
            var status = $(this).attr('s');
            $.post(url,{id:g_id,status:status},function (data) {
                alert(data.msg);
                if(data.code){
                    return;
                }else{
                    window.location.href=data.data;
                }
            },'json')
        });
    })
  </script>
</block>
